import { queryEntity } from '../../services/api';
import moment from 'moment';
import { getJdBalance, } from '../../services/product/api';


export default {
  namespace: 'homePage',

  state: {
    jdBalance: null,
  },

  effects: {
    *fetch({ payload }, { call, put }) {
      const response = yield call(getJdBalance);
      if (response && response.code == 200 && response.data) {
        yield put({
          type: 'save',
          payload: { jdBalance: response.data },
        });
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
        visitData: [],
        visitData2: [],
        salesData: [],
        searchData: [],
        offlineData: [],
        offlineChartData: [],
        salesTypeData: [],
        salesTypeDataOnline: [],
        salesTypeDataOffline: [],
        radarData: [],
      };
    },
  },
};
